package com.jws.jawestshow;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

import com.jws.thirdlibrary.CxManager;

public class RelayActivity extends Activity {

	private Button mButtonOpen;
	private Button mButtonClose;
	private CxManager mCxManager = null;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_relay);
		mCxManager = CxManager.create(this);
		initButton();
	}

	private void initButton()
	{
		mButtonOpen = (Button) findViewById(R.id.open);
		mButtonClose = (Button) findViewById(R.id.close);

		mButtonOpen.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				mCxManager.jwsOpenTheDoor();
				Toast.makeText(RelayActivity.this, R.string.jws_open_success, Toast.LENGTH_SHORT).show();
			}
		});

		mButtonClose.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				mCxManager.jwsCloseTheDoor();
				Toast.makeText(RelayActivity.this, R.string.jws_close_success, Toast.LENGTH_SHORT).show();
			}
		});
		
	}

}
